<?php
/*
* Class teia\webdev\php\core\SlideViewer
* Core class for displaying slides
*
* @author Bernardo Quibiana
* @date created: 20111202
*
* @date modified: 20111203
* @modified: Bernardo Quibiana
*/

// namespace declaration: Abstract Data Types
namespace teia\webdev\php\core;

require_once 'TypePool.inc';
require_once 'FunctionPool.inc';
require_once 'DisplayableItem.inc';

class SlideViewer extends DisplayableItem {
	
	private $images;
	private $width;
	private $height;
	
	public function __construct($images, $width=NULL, $height=NULL) {
		if (FunctionPool::check_elements_class($images, Image)) {
			$this->images = $images;
			$this->width = $width;
			$this->height = $height;
		} else {
			throw new \InvalidArgumentException('Invalid class for images, expected: Image', '999');
		}
	}
	
	public static function display_slideshow($imgs, $width=620, $height=320) {
		echo self::generate_slideshow($imgs, $width, $height);
	}
	
	public static function generate_slideshow($imgs, $width=620, $height=320) {
		$content = "<div id=\"slideshow\">\n";
		$content .= "\t<ul class=\"slides\">\n";
		foreach ($imgs as $txt => $img_path) {
			$content .= "\t\t<li><img src=\"$img_path\" width=\"$width\" height=\"$height\" alt=\"$txt\" /></li>\n";
		}
		$content .= "\t</ul\n";
		$content .= "\t<span class=\"arrow previous\"></span>\n";
		$content .= "\t<span class=\"arrow next\"></span>\n";
		$content .= "</div>\n";
	
		return $content;
	}
	/*
	 * <div id="slideshow">
					<ul class="slides">
		        		<li><img src="img/photos/1.jpg" width="620" height="320" alt="Marsa Alam" ></li>
		        		<li><img src="img/photos/2.jpg" width="620" height="320" alt="Turrimetta Beach" ></li>
		        		<li><img src="img/photos/3.jpg" width="620" height="320" alt="Power Station" ></li>
		        		<li><img src="img/photos/4.jpg" width="620" height="320" alt="Colors of Nature" ></li>
		    		</ul> 
		    		<span class="arrow previous"></span>
		    		<span class="arrow next"></span>
				</div>
	 */
}
?>